<HTML><HEAD><TITLE>atan(+Y, +X, -Result)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Arithmetic</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>atan(+Y, +X, -Result)</H1>
Computes the arc tangent function of two variables and unifies the resulting value with Result.
<DL>
<DT><EM>Y</EM></DT>
<DD>A number.
</DD>
<DT><EM>X</EM></DT>
<DD>A number.
</DD>
<DT><EM>Result</EM></DT>
<DD>A variable, float or breal.
</DD>
</DL>
<H2>Description</H2>
   This predicate is used by the ECLiPSe compiler to expand evaluable
   arithmetic expressions.  So the call to atan(Y, X, Result) is
   equivalent to
<PRE>
    Result is atan(Y, X)
</PRE>
    which should be preferred for portability.
<P>
    It is similar to calculating the arc tangent of Y/X, except that the
    signs of both arguments are used to determine the quadrant of the result.
    The result lies in the interval -pi..pi. The operation is valid even if
    X is zero, in which case the result is pi/2 or -pi/2.  One application
    is the conversion of cartesian to polar coordinates, where this function
    computes the angle component (in radians).
<P>
   In coroutining mode, if X or Y is uninstantiated, the call to atan/3 is
   delayed until both variables are instantiated.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>atan(+, +, -) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>X or Y is not instantiated (non-coroutining mode only).
<DT><EM>(24) number expected </EM>
<DD>Number is not of a numeric type.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      atan( 0.0, -1.0, Result).	(gives Result =  3.141592)
      atan( 1.0, -1.0, Result).	(gives Result =  2.356194)
      atan( 1.0,  0.0, Result).	(gives Result =  1.570796)
      atan( 1.0,  1.0, Result).	(gives Result =  0.785398)
      atan( 0.0,  0.0, Result).	(gives Result =  0.0)
      atan(-1.0,  1.0, Result).	(gives Result = -0.785398)
      atan(-1.0,  0.0, Result).	(gives Result = -1.570796)
      atan(-1.0, -1.0, Result).	(gives Result = -2.356194)
      atan(-0.0, -1.0, Result).	(gives Result = -3.141592)

      atan( 7.0,  7.0, Result).	(gives Result =  0.785398)

Fail:
      atan(1.55741, 0.0, 1).

Error:
      atan(A, 0.0, 6.0).              (Error 4).
      atan(1 + 0.55741, 1.0, R).      (Error 24).
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/arithmetic/is-2.html">is / 2</A>
</BODY></HTML>
